// 拼接HTTPUrl
function url(type, pathname) {
  return window.RPConfig[type] + pathname;
}

const ruleConfigApi = {
  createInfo: params => {
    return $http.post(url('itShare', '/itsRemindRule/insert'), params);
  },
  editInfo: params => {
    return $http.post(url('itShare', '/itsRemindRule/update'), params);
  },
  getDetail: params => {
    return $http.get(url('itShare', '/itsRemindRule/getById'), params);
  },
  getTableList: params => {
    return $http.post(url('itShare', '/itsRemindRule/page'), params);
  },
  deleteInfo: params => {
    return $http.post(url('itShare', '/itsRemindRule/delete'), params.data);
  },
  startOrStopRule: params => {
    return $http.post(url('itShare', `/itsRemindRule/changeStatus?id=${params.id}`));
  },

  // 2023-06-12 规则组接口
  createInfo2: params => {
    return $http.post(url('itShare', '/itsRemindRuleGroup/insert'), params);
  },
  editInfo2: params => {
    return $http.post(url('itShare', '/itsRemindRuleGroup/update'), params);
  },
  getDetail2: params => {
    return $http.get(url('itShare', '/itsRemindRuleGroup/getById'), params);
  },
  getTableList2: params => {
    return $http.post(url('itShare', '/itsRemindRuleGroup/page'), params);
  },
  deleteInfo2: params => {
    return $http.post(url('itShare', `/itsRemindRuleGroup/delete?ruleGroupId=${params.ruleGroupId}`), {});
  },
  deleteConfirm: params => {
    return $http.post(url('itShare', `/itsRemindRuleGroup/check?ruleGroupId=${params.ruleGroupId}`), {});
  },
  // 校验规则组是否存在规则触发时间早于提交时间
  checkRuleGroup: params => {
    return $http.post(url('itShare', `/itsRemindRuleGroup/submit/check`), params);
  },
  // 提交规则组
  submitRuleGroup: params => {
    return $http.post(url('itShare', `/itsRemindRuleGroup/submit?ruleGroupId=${params.ruleGroupId}`), {});
  },
  // 查询收件人组是否用于规则组
  getReceiverGroupUsed: params => {
    return $http.post(url('itShare', `/itsRemindRule/receiverGroup/used?id=${params.addressGroupId}`), {});
  },
};

export default ruleConfigApi;
